﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master/Site.Master" AutoEventWireup="true" CodeBehind="DataEnd.aspx.cs" Inherits="聚欣订单分析.OrderAna.DataEnd" %>

<%@ Register Assembly="DevExpress.Web.v18.1, Version=18.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CPH_NAV" runat="server">
    <h2>已结束项目</h2>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="CPH_Contents" runat="server">
    <asp:HiddenField ID="hfCxsql" runat="server" />
    <div class="content-page">
        <div class="content">
            <div class="am-g">
                <!-- Row start -->
                <div class="card-box">
                    <div class="am-g" style="padding-bottom: 10px">
                        <div class="am-u-sm-12 am-u-md-6">
                            <div class="am-btn-toolbar">
                            </div>
                        </div>

                        <div class="am-u-sm-12 am-u-md-3">
                            <div class="am-input-group am-input-group-sm">
                                <input id="txtContent" runat="server" type="text" class="am-form-field">
                                <span class="am-input-group-btn">
                                    <button class="am-btn am-btn-default" onclick="btnSel()" type="button">搜索</button>
                                </span>
                            </div>
                        </div>
                    </div>
                    <!--.am-form input[type="text"],-->
                    <dx:ASPxGridView ID="ASPxGridView1" runat="server" PreviewFieldName="description" Width="100%" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" KeyFieldName="ID"  OnCustomButtonCallback="ASPxGridView1_CustomButtonCallback" OnRowValidating="ASPxGridView1_RowValidating">
                        <ClientSideEvents EndCallback="function(s, e) {
	if (s.cpid!=undefined && s.cpmname!=undefined && s.cpaddperson!=undefined) { 
                    window.location.href='detailproject.aspx?id=' + s.cpid + '&mname=' + s.cpmname+'&addperson='+s.cpaddperson;
                    s.cpid =undefined;
                    s.cpmname=undefined; 
                    s.cpaddperson=undefined;
} 

}" />
                        <GroupSummary>
                            <dx:ASPxSummaryItem FieldName="money" DisplayFormat="金额：{0}万元" SummaryType="Sum" />
                            <dx:ASPxSummaryItem FieldName="name" DisplayFormat="项目总数：{0}" SummaryType="Count" />
                        </GroupSummary>

                        <EditFormLayoutProperties ColCount="1"></EditFormLayoutProperties>
                        <Columns>
                            <dx:GridViewCommandColumn Caption="选择" ShowSelectCheckbox="True" VisibleIndex="0" Width="40px">
                            </dx:GridViewCommandColumn>
                            <dx:GridViewDataTextColumn FieldName="ID" ReadOnly="True" Visible="false" VisibleIndex="1">
                                <EditFormSettings Visible="False" />
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn Caption="名称" FieldName="name" VisibleIndex="2">
                                <SettingsHeaderFilter Mode="CheckedList"></SettingsHeaderFilter>
                                <EditFormSettings Visible="True" />
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataComboBoxColumn Caption="区域" FieldName="region" VisibleIndex="3">
                                <SettingsHeaderFilter Mode="CheckedList"></SettingsHeaderFilter>
                                <PropertiesComboBox>
                                    <Items>
                                        <dx:ListEditItem Text="江苏" Value="江苏" />
                                        <dx:ListEditItem Text="山东" Value="山东" />
                                        <dx:ListEditItem Text="安徽" Value="安徽" />
                                        <dx:ListEditItem Text="湖北" Value="湖北" />
                                    </Items>
                                </PropertiesComboBox>
                            </dx:GridViewDataComboBoxColumn>
                            <dx:GridViewDataSpinEditColumn Caption="金额(万元)" FieldName="money" VisibleIndex="4">
                                <SettingsHeaderFilter Mode="CheckedList"></SettingsHeaderFilter>
                                <EditFormSettings Visible="True" />
                                <PropertiesSpinEdit DisplayFormatString="g"></PropertiesSpinEdit>
                            </dx:GridViewDataSpinEditColumn>
                            <dx:GridViewDataComboBoxColumn Caption="客户" FieldName="projecttype" VisibleIndex="5">
                                <SettingsHeaderFilter Mode="CheckedList"></SettingsHeaderFilter>
                                <EditFormSettings Visible="True" />
                                <PropertiesComboBox DataSourceID="SqlDataSource2" ValueField="ID" TextField="projectValue">
                                </PropertiesComboBox>
                            </dx:GridViewDataComboBoxColumn>
                            <dx:GridViewDataComboBoxColumn Caption="产品类型" FieldName="producttype" VisibleIndex="6">
                                <SettingsHeaderFilter Mode="CheckedList"></SettingsHeaderFilter>
                                <EditFormSettings Visible="True" />
                                <PropertiesComboBox DataSourceID="SqlDataSource3" ValueField="ID" TextField="productValue">
                                </PropertiesComboBox>
                            </dx:GridViewDataComboBoxColumn>
                            <dx:GridViewDataComboBoxColumn Caption="状态" FieldName="state" VisibleIndex="7">
                                <SettingsHeaderFilter Mode="CheckedList"></SettingsHeaderFilter>
                                <EditFormSettings Visible="True" />
                                <PropertiesComboBox DataSourceID="SqlDataSource4" ValueField="ID" TextField="stateValue">
                                </PropertiesComboBox>
                            </dx:GridViewDataComboBoxColumn>
                            <dx:GridViewDataTextColumn Caption="添加人" FieldName="addperson" VisibleIndex="8">
                                <SettingsHeaderFilter Mode="CheckedList"></SettingsHeaderFilter>
                                <EditFormSettings Visible="False" />
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataDateColumn Caption="添加时间" FieldName="addtime" VisibleIndex="9">
                            </dx:GridViewDataDateColumn>
                            <dx:GridViewDataMemoColumn Caption="描述" FieldName="description" VisibleIndex="10" Visible="false">
                                <EditFormSettings Visible="True" />
                                <PropertiesMemoEdit Rows="6">
                                </PropertiesMemoEdit>
                                <EditFormSettings ColumnSpan="2" />
                            </dx:GridViewDataMemoColumn>
                            <dx:GridViewDataTextColumn FieldName="action2" Visible="false" VisibleIndex="12">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewCommandColumn Caption="编辑" VisibleIndex="13" Width="40px" ShowEditButton="true" ShowUpdateButton="true" ShowCancelButton="true">
                            </dx:GridViewCommandColumn>
                            <dx:GridViewCommandColumn Caption="跟踪" Width="40px" VisibleIndex="14">
                                <CustomButtons>
                                    <dx:GridViewCommandColumnCustomButton ID="CbtnGz" Text="跟踪">
                                    </dx:GridViewCommandColumnCustomButton>
                                </CustomButtons>
                            </dx:GridViewCommandColumn>
                            <%--   <dx:GridViewCommandColumn Caption="编辑操作" VisibleIndex="13" Width="90px">
                                    <EditButton Text="查看/编辑" Visible="True">
                                    </EditButton>
                                    <DeleteButton Text="删除" Visible="True">
                                    </DeleteButton>
                                    <UpdateButton Text="确定" Visible="true"></UpdateButton>
                                    <CancelButton Text="取消" Visible="true"></CancelButton>
                                    <ClearFilterButton Text="取消查询" Visible="true"></ClearFilterButton>
                                </dx:GridViewCommandColumn>
                                <dx:GridViewCommandColumn Caption="置顶操作" Width="60px" VisibleIndex="14">
                                    <CustomButtons>
                                        <dx:GridViewCommandColumnCustomButton ID="CbtnZd" Text="置顶/取消">
                                        </dx:GridViewCommandColumnCustomButton>
                                    </CustomButtons>
                                </dx:GridViewCommandColumn>
                                <dx:GridViewCommandColumn Caption="项目跟踪" Width="80px" VisibleIndex="14">
                                    <CustomButtons>
                                        <dx:GridViewCommandColumnCustomButton ID="CbtnGz" Text="查看/添加跟踪">
                                        </dx:GridViewCommandColumnCustomButton>
                                    </CustomButtons>
                                </dx:GridViewCommandColumn>--%>
                        </Columns>

                        <SettingsAdaptivity>
                            <AdaptiveDetailLayoutProperties ColCount="1"></AdaptiveDetailLayoutProperties>
                        </SettingsAdaptivity>

                        <Templates>
                            <PreviewRow>
                                <%bool t = IsMobile; %>
                                <%if (t)%><%
                                              {%>
                                <table style="border: none">
                                    <tr>
                                        <td>项目名称：<%# Eval("name") %></td>
                                    </tr>
                                    <tr>
                                        <td>项目类型：<%# Eval("projectValue") %>&nbsp;&nbsp;产品类型：<%# Eval("productValue") %></td>
                                    </tr>
                                    <tr>
                                        <td>添&nbsp;&nbsp;加&nbsp;&nbsp;人：<%# Eval("addperson") %>&nbsp;&nbsp;更新时间：<%# DateTime.Parse(Eval("addtime").ToString()).ToString("yyyy-MM-dd") %></td>
                                    </tr>
                                    <tr>
                                        <td><%# Eval("description") %></td>
                                    </tr>
                                </table>
                                <%}
                                    else
                                    {%>
                                <table style="border: none">
                                    <tr>
                                        <td><%# Eval("description") %></td>
                                    </tr>
                                </table>
                                <%}%>
                                <%# Gznew(Eval("ID")) %>
                            </PreviewRow>
                        </Templates>
                        <TotalSummary>
                            <dx:ASPxSummaryItem FieldName="region" DisplayFormat="总额:" SummaryType="Count" />
                            <dx:ASPxSummaryItem FieldName="money" DisplayFormat="{0}万元" SummaryType="Sum" />
                        </TotalSummary>
                        <SettingsBehavior ConfirmDelete="true" />
                        <SettingsEditing EditFormColumnCount="1" />
                        <SettingsPager PageSize="20">
                        </SettingsPager>
                        <Settings ShowFooter="true" ShowPreview="true" ShowHeaderFilterButton="true" />
                        <SettingsLoadingPanel Delay="3000" ShowImage="False" />
                        <SettingsText ConfirmDelete="删除项目同时会删除本项目所有的跟踪信息，确认删除吗？" />
                        <SettingsPopup>
                            <HeaderFilter>
                                <SettingsAdaptivity Mode="Always" SwitchAtWindowInnerWidth="768" />
                            </HeaderFilter>
                        </SettingsPopup>
                    </dx:ASPxGridView>
                </div>
            </div>
            <!-- Row end -->
        </div>
    </div>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:JXDDConnectionString %>" SelectCommand="SELECT * FROM [v_maintable] ORDER BY action2 DESC,addtime DESC"
        UpdateCommand="UPDATE [dbo].[maintable]
   SET [name] = @name
      ,[region] = @region
      ,[money] = @money
      ,[projecttype] = @projecttype
      ,[producttype] = @producttype
      ,[state] = @state
      ,[description] = @description
      ,[addtime] = @addtime
 WHERE ID=@ID"
        InsertCommand="INSERT INTO [dbo].[maintable]
           ([name]
           ,[region]
           ,[money]
           ,[projecttype]
           ,[producttype]
           ,[state]
           ,[addperson]
           ,[addtime]
           ,[description]
           ,[action1]
           ,[action2])
     VALUES
           (@name
           ,@region
           ,@money
           ,@projecttype
           ,@producttype
           ,@state
           ,@addperson
           ,GETDATE()
           ,@description
           ,1
           ,1)"
        DeleteCommand="DELETE FROM maintable WHERE ID=@ID">
        <UpdateParameters>
            <asp:Parameter Name="name" />
            <asp:Parameter Name="region" />
            <asp:Parameter Name="money" />
            <asp:Parameter Name="projecttype" />
            <asp:Parameter Name="producttype" />
            <asp:Parameter Name="state" />
            <asp:Parameter Name="description" />
            <asp:Parameter Name="addtime" />
            <asp:Parameter Name="ID" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="name" />
            <asp:Parameter Name="region" />
            <asp:Parameter Name="money" />
            <asp:Parameter Name="projecttype" />
            <asp:Parameter Name="producttype" />
            <asp:Parameter Name="state" />
            <asp:SessionParameter Name="addperson" SessionField="realname" />
            <asp:Parameter Name="description" />
        </InsertParameters>
        <DeleteParameters>
            <asp:Parameter Name="ID" />
        </DeleteParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:JXDDConnectionString %>" SelectCommand="SELECT * FROM [projectmanage]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:JXDDConnectionString %>" SelectCommand="SELECT * FROM [productmanage]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:JXDDConnectionString %>" SelectCommand="SELECT * FROM [statemanage]"></asp:SqlDataSource>
</asp:Content>
